package com.yingsheng.bi.hks.template.element;

import com.yingsheng.bi.hks.template.events.ElementEvent;
import com.yingsheng.bi.hks.template.processor.ElementProcessor;
import org.springframework.util.ObjectUtils;

public class NotEmptyElementProcessor implements ElementProcessor {

    @Override
    public void exec(ElementEvent event) {
        Object value = event.getInput();
        if (ObjectUtils.isEmpty(value)) {
            fail(event.getName());
        }
    }

    private void fail(String name) {
        throw new IllegalArgumentException("parameter " + name + " not empty");
    }
}
